package com.lingying.caiwudailikehudaun.mapper.dianZiShuiWuJuShenBaoJiLu;

import com.lingying.caiwudailikehudaun.domain.shenBao.ShenBaoBaen;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Mapper
public interface DianZiShuiWuJuShenBaoJiLuMapper {

    /**电子税务局申报
     * 申报记录历史信息
     * 桑满20210623
     * @param zuoZhangShenBaoId
     * @param suoShuYueFen
     * @param gongSiMingCheng
     * @param shenBaoRenId
     * @param pages
     * @param limit
     * @return
     */
    @Select({"<script>" +
            " SELECT s.*,c.zhuGuanName,c.caiWuFuWuRenYuanName,c.shenBaoRenYuanName,c.zuoZhangRenYuanName,c.shenHeRenName " +
            "FROM shenBao s INNER JOIN caiWuFenPei c ON s.daiLiShangCid = c.daiLiShangCid where s.zuoZhangShenBaoId=#{zuoZhangShenBaoId} " +
            " and s.xianShiZhuangTai = 0 AND s.fuWuZhuangTai = 0 " +
            "<if test=\" suoShuYueFen!=null and suoShuYueFen!='' \">" +
            " and s.suoShuYueFen like concat (#{suoShuYueFen},'%') " +
            "</if>" +
            " AND c.xianShiZhuangTai = 1 " +
            " ORDER BY s.suoShuYueFen DESC limit #{pages},#{limit}" +
            "</script>"})
    List<ShenBaoBaen> selectShenBaoJiLu(Integer zuoZhangShenBaoId,String suoShuYueFen,String gongSiMingCheng,Integer shenBaoRenId,Integer pages,Integer limit);
    //总个数
    @Select({"<script>" +
            " select count(1) " +
            "FROM shenBao s INNER JOIN caiWuFenPei c ON s.daiLiShangCid = c.daiLiShangCid where s.zuoZhangShenBaoId=#{zuoZhangShenBaoId}" +
            " and s.xianShiZhuangTai = 0 AND s.fuWuZhuangTai = 0 " +
            "<if test=\" suoShuYueFen!=null and suoShuYueFen!='' \">" +
            " and s.suoShuYueFen like concat (#{suoShuYueFen},'%') " +
            "</if>" +
            " AND c.xianShiZhuangTai = 1 " +
            "</script>"})
    Integer selectShenBaoJiLuCount(Integer zuoZhangShenBaoId,String suoShuYueFen,String gongSiMingCheng,Integer shenBaoRenId);

    /**个税申报
     * 申报记录历史信息
     * 桑满20210623
     * @param zuoZhangShenBaoId
     * @param suoShuYueFen
     * @param gongSiMingCheng
     * @param shenBaoRenId
     * @param pages
     * @param limit
     * @return
     */
    @Select({"<script>" +
            " SELECT s.*,c.zhuGuanName,c.caiWuFuWuRenYuanName,c.shenBaoRenYuanName,c.zuoZhangRenYuanName,c.shenHeRenName " +
            "FROM shenBao s INNER JOIN caiWuFenPei c ON s.daiLiShangCid = c.daiLiShangCid where s.zuoZhangShenBaoId=#{zuoZhangShenBaoId}" +
            " and  s.xianShiZhuangTai = 0 AND s.fuWuZhuangTai = 0 " +
            "<if test=\" suoShuYueFen!=null and suoShuYueFen!='' \">" +
            " and s.suoShuYueFen like concat (#{suoShuYueFen},'%') " +
            "</if>" +
            " and c.xianShiZhuangTai = 1 " +
            " ORDER BY s.suoShuYueFen DESC LIMIT #{pages},#{limit}" +
            "</script>"})
    List<ShenBaoBaen> selectGeShuiShenBaoJiLu(Integer zuoZhangShenBaoId, String suoShuYueFen, String gongSiMingCheng, Integer shenBaoRenId, Integer pages, Integer limit);
    //总个数
    @Select({"<script>" +
            " select count(1) " +
            "FROM shenBao s INNER JOIN caiWuFenPei c ON s.daiLiShangCid = c.daiLiShangCid where s.zuoZhangShenBaoId=#{zuoZhangShenBaoId}" +
            " and s.xianShiZhuangTai = 0 AND s.fuWuZhuangTai = 0 " +
            "<if test=\" suoShuYueFen!=null and suoShuYueFen!='' \">" +
            " and s.suoShuYueFen like concat (#{suoShuYueFen},'%') " +
            "</if>" +
            "and c.xianShiZhuangTai = 1 " +
            "</script>"})
    Integer selectGeShuiShenBaoJiLuCount(Integer zuoZhangShenBaoId,String suoShuYueFen,String gongSiMingCheng,Integer shenBaoRenId);

    /**
     * 查询该公司下已经上传的申报成功的截图（电子税务局）
     * 桑满 202210629
     */
    @Select("SELECT companyName,dianZiShuiWuJuShenBaoJieTu FROM shenBao WHERE zuoZhangShenBaoId = #{zuoZhangShenBaoId} AND suoShuYueFen LIKE CONCAT(#{suoShuYueFen},'%')")
    Map<String, Object> selectShenBaoJieTuShuiJu(Integer zuoZhangShenBaoId, String suoShuYueFen);


    /**
     * 查询该公司下已经上传的申报成功的截图（个税）
     * 桑满 202210629
     */
    @Select("SELECT geShuiShenBaoJieTu,companyName FROM shenBao WHERE zuoZhangShenBaoId = #{zuoZhangShenBaoId} AND suoShuYueFen LIKE CONCAT(#{suoShuYueFen},'%')")
    Map<String, Object> selectShenBaoJieTuGeShui(Integer zuoZhangShenBaoId, String suoShuYueFen);
}
